package com.pomr.model.synthesize;

import java.io.Serializable;
import java.util.Date;
import java.util.Set;

import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.OneToMany;
import javax.persistence.Table;
import javax.persistence.Temporal;
import javax.persistence.TemporalType;
import javax.persistence.UniqueConstraint;

import org.hibernate.annotations.Formula;
import org.hibernate.annotations.GenericGenerator;

import com.alibaba.fastjson.annotation.JSONField;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.pomr.model.sys.Agency;
import com.pomr.model.sys.User;

/**
 * 厂商信息
 * @author Administrator
 *
 */
@Entity
@Table(name="manufacturer",uniqueConstraints = {@UniqueConstraint(columnNames={"jgdm"})})
public class Manufacturer implements Serializable{
	
	public String getJgdm() {
		return jgdm;
	}
	public void setJgdm(String jgdm) {
		this.jgdm = jgdm;
	}
	public String getKjm() {
		return kjm;
	}
	public void setKjm(String kjm) {
		this.kjm = kjm;
	}
	public Set<Linkman> getLinkmans() {
		return linkmans;
	}
	public void setLinkmans(Set<Linkman> linkmans) {
		this.linkmans = linkmans;
	}
	public String getRemark() {
		return remark;
	}
	public void setRemark(String remark) {
		this.remark = remark;
	}
	public Date getCreateTime() {
		return createTime;
	}
	public void setCreateTime(Date createTime) {
		this.createTime = createTime;
	}
	public User getUser() {
		return user;
	}
	public void setUser(User user) {
		this.user = user;
	}
	public String getUserName() {
		return userName;
	}
	public void setUserName(String userName) {
		this.userName = userName;
	}
	public Integer getId() {
		return id;
	}
	public void setId(Integer id) {
		this.id = id;
	}
	public String getName() {
		return name;
	}
	public void setName(String name) {
		this.name = name;
	}
	public String getTel() {
		return tel;
	}
	public void setTel(String tel) {
		this.tel = tel;
	}
	public String getEmail() {
		return email;
	}
	public void setEmail(String email) {
		this.email = email;
	}
	public String getAddr() {
		return addr;
	}
	public void setAddr(String addr) {
		this.addr = addr;
	}
	public int getStatus() {
		return status;
	}
	public void setStatus(int status) {
		this.status = status;
	}
	@Id
	@GeneratedValue(strategy = GenerationType.AUTO, generator = "native")
    @GenericGenerator(name = "native", strategy = "native")//AUTO 在mysql中需要指定使用本地策略生成主键值
	private Integer id;//主键
	@Column(name="name",length=50)
	private String name;//厂商名称
	@Column(name="tel",length=20)
	private String tel;//联系方式
	@Column(name="email",length=20)
	private String email;//邮箱
	@Column(name="addr",length=50)
	private String addr;//地址
	@Column(name="status")
	private int status;//状态
	@Column(name="remark",length=100)
	private String remark;//备注
	@Column(name="jgdm",length=30,nullable=false)
	private String jgdm;//唯一组织结构代码
	@Column(name="kjm",length=20)
	private String kjm;//快捷码
	@JsonFormat(locale="zh", timezone="GMT+8", pattern="yyyy-MM-dd HH:mm:ss")
	@Column(name="create_time")
	private Date createTime;//创建时间
	
	@ManyToOne(fetch=FetchType.LAZY)
	@JoinColumn(name="createuser_id")
	private User user;//创建人
	
	@Formula("(select u.name from user u where u.id=createuser_id)")
	private String userName;
	
	@OneToMany(fetch=FetchType.LAZY,cascade=CascadeType.ALL)//级联操作
	@JoinColumn(name="manufacturer_id")
	private Set<Linkman> linkmans;
	
}
